In [ ]:
%pylab inline
import pandas as pd
pd.__version__

The file read in the notebook is created in mActions.py with the code:

import csv
        common.csvf=open(common.pro + "/" +\
           "firstStepOutputInHayekianMarket.csv", "w")
        common.wr=csv.writer(common.csvf)
        common.closed=False

The code used to generate the content of the file, after each action within the macro act, is reported with the different cases.

case nogoods

no prices (buy or sell); consumption as residual cons. capability of the buyer, in value; id both of the buyer and of the seller

#ouput -  seller has no goods to sell
elif common.cycle==common.startHayekianMarket:
         common.wr.writerow\
         (["nogoods", "buy", numpy.nan, self.consumption, \
         self.number,\
         "sell", numpy.nan,mySeller.number])

cases deal, nodeal

prices (buy and sell); consumption as residual cons. capability of the buyer, in value; id both of the buyer and of the seller

#output - deal vs. nodeal
if common.cycle==common.startHayekianMarket:
     if mySeller.statusS==1:
        common.wr.writerow\
        (["deal", "buy", self.buyPrice, self.consumption, \
        self.number,\
        "sell", mySeller.sellPrice,mySeller.number])
     if mySeller.statusS==-1 and mySeller.sellPriceDefined:
        common.wr.writerow\
        (["nodeal", "buy", self.buyPrice, self.consumption, \
        self.number,\
        "sell", mySeller.sellPrice,mySeller.number])

case seller list empty

unique price (buy); consumption as residual cons. capability of the buyer, in value; id uniquely of the buyer

#output - self.sellerList==[]
elif common.cycle==common.startHayekianMarket:
     common.wr.writerow\
      (["nosellers", "buy", self.buyPrice, self.consumption, \
      self.number,\
      "sell", numpy.nan,numpy.nan])

case no more consumption capability

no prices (buy or sell); consumption as residual cons. capability of the buyer, as $0$ value; id uniquely of the buyer

#output - self.consumption<=0
elif common.cycle==common.startHayekianMarket:
     common.wr.writerow\
       (["noconsumption", "buy", numpy.nan, self.consumption, \
       self.number,\
       "sell", numpy.nan,numpy.nan])

In [ ]:
df=pd.read_csv('firstStepOutputInHayekianMarket.csv',\
               header=None,usecols=[0,2,3,6],names=['result',
              'buy price','res. consumption','sell price'])

In [ ]:
# a sample with the initial rows of the file; to see more, try (as an example)
# df.head(10)
df.head()

In [ ]:
# count of the records by col names (excluding nan cases)
df.count()
# to understand try df[0:10].count() or so, looking at the file
# NB a residual consumption (res. consumprion) value equal to 0 
# is anyway considered as a valid value

In [ ]:
# contents of the col 'result' and their numbner of not nan cases
# NB a residual consumption (res. consumprion) value equal to 0 
# is anyway considered as a valid value
df.groupby('result').count()

In [ ]:
df.describe()

In [ ]:
# create a new variable 'deal' with true if ...
deal = df['result'] == "deal"

In [ ]:
# used only to undestand the operation above
df[df['result'] == "deal"].head()

In [ ]:
# the output here is the same above
df[deal].head()

In [ ]:
df[deal].describe(include=numpy.number)

In [ ]:
df.plot(figsize=(10,4),color=['b','g','r'])

In [ ]:
# last substep
df.tail(10010).plot(figsize=(10,4),color=['b','g','r'])

In [ ]:
# last substepTotal = df['MyColumn'].sum()
df.tail(10010)["res. consumption"].sum()
# risultato dopo 100 tentativi di acquisto

In [ ]:
df.tail(1000).plot(figsize=(10,4),color=['b','g','r'])

In [ ]:
df.tail(75000).groupby('result').count()

In [ ]:
df.head(2500).drop(columns='res. consumption').plot(figsize=(10,4),color=['b','r'])

In [ ]:
df[deal].head(2500).drop(columns='res. consumption').plot(figsize=(10,4),color=['b','r'])

In [ ]:
df[deal][100:250].drop(columns='res. consumption').plot(figsize=(10,4),color=['b','r'])

In [ ]:
df.drop(columns='res. consumption').plot(figsize=(10,4),color=['b','r'])

In [ ]:
#df.tail(1000).drop(columns=['buy','sell']).plot(figsize=(10,4),color='g')
#df.head(1000).drop(columns=['buy','sell']).plot(figsize=(10,4),color='g')
df.drop(columns=['buy price','sell price']).plot(figsize=(10,4),color='g')

In [ ]:
df[deal].drop(columns='res. consumption').plot(figsize=(10,4),color=['b','r'])

In [ ]:
df[deal].head(10000).drop(columns='res. consumption').plot(figsize=(10,4),color=['b','r'])

In [ ]:
df[deal].head(1000).describe(include=numpy.number,percentiles=[.25, .5, .75,0.95])

In [ ]:
df.head(1000).describe(include=numpy.number,percentiles=[.25, .5, .75,0.95])

In [ ]: